/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DBA;
 import baseDeDatos.ConexionMySQL;
import java.awt.Checkbox;
 import java.sql.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.JOptionPane;
import javax.swing.JTabbedPane;
import java.lang.Object;
import javax.swing.DefaultCellEditor;
import javax.swing.JCheckBox;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
/**
 *
 * @author Jorge
 */
public class DBA_LugarRealizacion {
    
    public DefaultTableModel  Recuperar (String dato){
        ConexionMySQL mysql = new ConexionMySQL();
        Connection conector = mysql.Conectar();
        String[] titulos = {"Lugar", "Disponibilidad","Seleccion","","",""};
        Object[] registro = new Object[6];
        String sSQL = "";
        
        DefaultTableModel modelo = new javax.swing.table.DefaultTableModel(
                
                
            new Object [][] {
            },
            new String [] {
                "Lugar", "Disponibilidad","Seleccion",null,null,null
            }){
            Class[] types = new Class [] {
                java.lang.Object.class, java.lang.Object.class, java.lang.Boolean.class, java.lang.Object.class,java.lang.Object.class,java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                true, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            
        };
                
      
        
        
        
       sSQL = "SELECT  L.nombre,U.disponible, L.idLugarDeRealizacion, L.descripcion, L.eliminado FROM  (SELECT idDeporte FROM deporte WHERE nombre= \""+dato+"\" ) AS P,usa AS U, lugarderealizacion AS L  WHERE  P.idDeporte = U.idDeporteFo AND L.idLugarDeRealizacion=U.idLugarDeRealizacionFo AND U.idDeporteFo=P.idDeporte";
       
               try
        {
            Statement st = conector.createStatement();
            ResultSet rs = st.executeQuery(sSQL);
    

            while(rs.next())
            {
                registro[0] = rs.getString("L.nombre");
                registro[1] = rs.getInt("U.disponible");
                registro[2] = new Boolean(false);
                registro[3]=  rs.getInt("L.idLugarDeRealizacion");
                registro[4]=  rs.getString("L.descripcion");
                registro[5]=  rs.getInt("L.eliminado");
                
                modelo.addRow(registro);
            }
            return modelo;
           

        } 
        catch (SQLException ex)
        {
            JOptionPane.showMessageDialog(null, ex);
            return modelo;
        }
        

    }
    
}
